package com.jld.lambda;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.function.IntBinaryOperator;

@SpringBootTest
public class demo1 {
    public static void main(String[] args) {
//        int i=caculateNum(new IntBinaryOperator() {
//            @Override
//            public int applyAsInt(int left, int right) {
//                return left+right;
//            }
//        });
//    }

/**
 * lambda表达式
 *只注重参数列表和函数体
 */
        int i = caculateNum((int left, int right) -> left + right);
    }
@Test
    public static int caculateNum(IntBinaryOperator operator) {
        int a = 10;
        int b = 20;
        return operator.applyAsInt(a, b);
    }
}
